<template>
	<view class="userReview">
		<watermark></watermark>
		<view class="pad20">
			<view class="zyjz space-between f28 pad-t-30 pad-b-30 border-b">
				<text class="clAAA">姓名</text>
				<text>{{dataValue.user_name}}</text>
			</view>
			<view class="zyjz space-between f28 pad-t-30 pad-b-30 border-b">
				<text class="clAAA">手机</text>
				<text>{{dataValue.mobile_phone}}</text>
			</view>
			<view class="zyjz space-between f28 pad-t-30 pad-b-30 border-b">
				<text class="clAAA">身份</text>
				<text>{{getType(dataValue.type)}}</text>
			</view>
			<view class="zyjz space-between f28 pad-t-30 pad-b-30 border-b" v-if="item.type !== 'warehouse'">
				<text class="clAAA">班组</text>
				<text>{{dataValue.class_name}}</text>
			</view>
			<view class="zyjz space-between f28 pad-t-30 pad-b-30 border-b">
				<text class="clAAA">加入仓库</text>
				<text>{{dataValue.warehouse_name}}</text>
			</view>
			<!-- <view class=" f28 pad-t30 pad-b-30 border-b">
				<text class="clAAA">已加入仓库</text>
				<view class="zyjz mgn-t-20 f26">
					<view class="warehouse-name mgn-r-20" v-for="(item) in 5">冯瑞</view>
				</view>

			</view> -->

		</view>
		<view class="bottom zyjz pad-l-40 pad-t-20 pad-b-20 pad-r-20 bgfff f28 cl343 space-between ">
			<button type="primary" style="width: 48%;" hover-class="none" @click="onPass">审核通过</button>
			<button type="default" style="width: 48%;" hover-class="none" plain @click="onRefuse">拒绝审核</button>
		</view>

		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog ref="inputClose" mode="input" title="拒绝原因" placeholder="请输入拒绝原因"
				@confirm="dialogInputConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import watermark from '@/components/watermark.vue'
	import mixins from '@/mixins/index.js'
	export default {
		mixins: [mixins],
		components: {
			watermark
		},
		data() {
			return {
				id: '',
				userId: '',
				dataValue: {}
			}
		},
		onLoad(e) {
			if (e && e.id) {
				this.id = e.id
				this.userId = e.userId
				this.getDet()
			}
		},
		methods: {
			getType(e) {
				switch (e) {
					case 'warehouse':
						return '仓管'
					case 'team':
						return '班头'
					case 'user':
						return '用户'
				}
			},
			getDet() {
				this.api.get('users/details', {
					user_id: this.userId
				}).then(res => {
					this.dataValue = res.data
				})
			},
			onPass() {
				const obj = {
					type: this.type,
					id: this.id,
					pass: 1,
				}
				this.api.post('audit', obj).then(res => {
					this.api.msg('审核成功')
					setTimeout(() => {
						this.back()
					}, 2000)
				})
			},
			onRefuse() {
				this.$refs.inputDialog.open()
			},
			dialogInputConfirm(val) {
				const obj = {
					type: this.type,
					id: this.id,
					pass: 2,
					note: val
				}
				this.api.post('audit', obj).then(res => {
					this.$refs.inputDialog.close()
					this.api.msg('拒绝成功')
					setTimeout(() => {
						this.back()
					}, 2000)
				})

			}
		}
	}
</script>

<style lang="less">
	.userReview {
		.border-b {
			border-bottom: 1px solid #F7F7F7;
		}

		.warehouse-name {
			padding: 15rpx 30rpx;
			background: #EEEEEE;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
		}
	}
</style>